package com.sinopec.android.receiver;


import com.sinopec.android.service.NotificationService;
import com.sinopec.android.util.LogUtil;
import com.sinopec.android.util.SharePreferencesUtil;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class BootBroadcastReceiver extends BroadcastReceiver {

	  @Override 

      public void onReceive(Context context, Intent intent) { 
		  //开机自启动
		  if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
	          // Start the service
	          Intent notification = new Intent(context, NotificationService.class);  
	          context.startService(notification);
		  }
		  //软件安装
		  if (intent.getAction().equals("android.intent.action.PACKAGE_ADDED")) {   
	             String packageName = intent.getDataString();   
	             LogUtil.printInfo("PACKAGE_ADDED:" + packageName);   
	         }   
		 //软件卸载    
		  if (intent.getAction().equals("android.intent.action.PACKAGE_REMOVED")) {   
	          String packageName = intent.getDataString();   
	          if("com.sinopec.android".equals(packageName)){
	        	  LogUtil.printInfo("PACKAGE_REMOVED：" + packageName);   
	        	  SharePreferencesUtil.clearLoginUserMemberId(context);
	          }
	         }   

      } 



}
